﻿app.controller('SafetyIndexController', function ($scope, $http, $window, $compile, $filter, ipCookie, common, option, Upload) {
    $scope.result = {};
    $scope.dateOption = option.date;
    $scope.datetimeOption = option.datetime;

    $scope.GetSafetyIndexTypeList = function () {
        $scope.DataLoading = true;
        $scope.TypeList = [];
        $http({
            method: 'POST',
            url: '../SafetyIndex/GetIndexTypeList'
        })
            .success(function (ret) {
                $scope.DataLoading = false;
                common.success($scope, null, ret);
                $scope.TypeList = ret.Data;
            })
            .error(function (data, status, headers, config) {
                $scope.DataLoading = false;
            });
    }

    $scope.GetSafetyIndexItemList = function (id) {
        $scope.DataLoading = true;
        $scope.ItemList = [];
        $http({
            method: 'POST',
            url: '../SafetyIndex/GetSafetyIndexItemList',
            data: { "TypeId": id }
        })
            .success(function (ret) {
                $scope.DataLoading = false;
                common.success($scope, null, ret);
                $scope.ItemList = ret.Data;
            })
            .error(function (data, status, headers, config) {
                $scope.DataLoading = false;
            });
    }
    $scope.GetEventList = function (id, time) {
        $scope.DataLoading = true;
        $scope.EventList = [];
        $http({
            method: 'POST',
            url: '../SafetyIndex/GetEventList',
            data: { "TypeId": id, 'EventTime': time }
        })
            .success(function (ret) {
                $scope.DataLoading = false;
                common.success($scope, null, ret);
                $scope.EventList = ret.Data;
                var type_r = 0;
                var type_j = 0;
                var type_h = 0;
                var type_g = 0;
                var type_all = 0;
                for (var i = 0; i < $scope.EventList.length; i++) {
                    var item = $scope.EventList[i];
                    type_all += item.DataValue;
                    if (item.PartentIndexName == '人') {
                        type_r += item.DataValue;
                    }
                    else if (item.PartentIndexName == '机') {
                        type_j += item.DataValue;
                    }
                    else if (item.PartentIndexName == '环') {
                        type_h += item.DataValue;
                    }
                    else if (item.PartentIndexName == '管') {
                        type_g += item.DataValue;
                    }
                }
                if (type_all == 0) {
                    type_all = 10;
                }
                $scope.DetailScore = {
                    "zb1": type_r,
                    "zb2": type_j,
                    "zb3": type_h,
                    "zb4": type_g,
                    "zb0": type_all
                };

            })
            .error(function (data, status, headers, config) {
                $scope.DataLoading = false;
            });
    }
    $scope.GetMySafetyIndexTypeList = function () {
        $scope.DataLoading = true;
        $scope.TypeList = [];
        $http({
            method: 'POST',
            url: '../SafetyIndex/GetMyIndexTypeList'
        })
            .success(function (ret) {
                $scope.DataLoading = false;
                common.success($scope, null, ret);
                $scope.TypeList = ret.Data;
            })
            .error(function (data, status, headers, config) {
                $scope.DataLoading = false;
            });
    }
    $scope.RemoveIndexItem = function (Id, page) {
        alertify.okBtn("确认")
            .cancelBtn("取消").confirm("确认撤销该记录？", function (ev) {
                ev.preventDefault();
                $http({
                    method: 'POST',
                    url: '../SafetyIndex/RemoveIndexFormItem',
                    data: { 'Id': Id, 'Status': 0 }
                })
                    .success(function (ret) {
                        common.success($scope, null, ret);
                        if (ret.Code == 100) {
                            alertify.alert("操作成功！");
                            $scope.GetIndexItemPageList(page);
                            $scope.GetMySafetyIndexTypeList();
                        } else
                            alertify.alert(ret.Msg);

                    })
                    .error(function (data, status, headers, config) {
                    });
            }, function (ev) {
                ev.preventDefault();
            });
    }

    $scope.RestoreIndexItem = function (Id, page) {
        alertify.okBtn("确认")
            .cancelBtn("取消").confirm("确认恢复该记录？", function (ev) {
                ev.preventDefault();
                $http({
                    method: 'POST',
                    url: '../SafetyIndex/RemoveIndexFormItem',
                    data: { 'Id': Id, 'Status': 1 }
                })
                    .success(function (ret) {
                        common.success($scope, null, ret);
                        if (ret.Code == 100) {
                            alertify.alert("操作成功！");
                            $scope.GetIndexItemPageList(page);
                            $scope.GetMySafetyIndexTypeList();
                        } else
                            alertify.alert(ret.Msg);

                    })
                    .error(function (data, status, headers, config) {
                    });
            }, function (ev) {
                ev.preventDefault();
            });
    }

    $scope.DeleteIndexItem = function (Id, page) {
        alertify.okBtn("确认")
            .cancelBtn("取消").confirm("确认删除该记录？", function (ev) {
                ev.preventDefault();
                $http({
                    method: 'POST',
                    url: '../SafetyIndex/DeleteIndexFormItem',
                    data: { 'Id': Id }
                })
                    .success(function (ret) {
                        common.success($scope, null, ret);
                        if (ret.Code == 100) {
                            alertify.alert("操作成功！");
                            $scope.GetIndexItemPageList(page);
                            $scope.GetMySafetyIndexTypeList();
                        } else
                            alertify.alert(ret.Msg);

                    })
                    .error(function (data, status, headers, config) {
                    });
            }, function (ev) {
                ev.preventDefault();
            });
    }




    $scope.InitIndexItemForm = function (model) {
        $scope.AddModel.TypeId = model.Id;
        $scope.AddModel.EventTime = $scope.formatDate(new Date());
        $scope.AddModel.Description = '';
        $scope.AddModel.DataValue = 1;
        $scope.AddModel.TypeName = model.IndexName;
    }

    $scope.SubmitIndexFormItem = function (model) {
        $scope.DataLoading = true;
        $http({
            method: 'POST',
            url: '../SafetyIndex/AddSafetyIndexItem',
            data: { 'model': model }
        })
            .success(function (ret) {
                $scope.DataLoading = false;
                common.success($scope, null, ret);

                if (ret.Code == 100) {
                    alertify.alert("保存成功！");
                    setTimeout(function () {
                        $("#btn_close").click();
                        $scope.GetIndexItemPageList(1);
                        $scope.GetMySafetyIndexTypeList();
                    }, 2000);
                } else
                    alertify.alert(ret.Msg);
            })
            .error(function (data, status, headers, config) {
                $scope.DataLoading = false;
            });
    }

    $scope.GetIndexItemPageList = function (page) {
        $scope.DataLoading = true;
        $scope.IndexItemList = [];
        $http({
            method: 'POST',
            url: '../SafetyIndex/GetSafetyIndexItemPageList',
            data: { 'page': page, 'pageSize': 20 }
        })
            .success(function (ret) {
                $scope.DataLoading = false;
                common.success($scope, null, ret);
                $scope.IndexItemList = ret.Data.Data;
                $scope.TotalCount = ret.Data.TotalItemCount;

            })
            .error(function (data, status, headers, config) {
                $scope.DataLoading = false;
            });

    }

    $scope.formatDate = function (date) {
        const year = date.getFullYear();
        const month = ('0' + (date.getMonth() + 1)).slice(-2);
        const day = ('0' + date.getDate()).slice(-2);
        const hours = ('0' + date.getHours()).slice(-2);
        const minutes = ('0' + date.getMinutes()).slice(-2);
        const seconds = ('0' + date.getSeconds()).slice(-2);
        return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
    }

    $scope.SubmitIndexForm = function () {
        var datalist = [];
        $scope.DataLoading = true;
        var inputlist = $('input[name^="datavalue"]');
        for (var i = 0; i < inputlist.length; i++) {
            var obj = {
                "TypeId": inputlist[i].id,
                "DataValue": $(inputlist[i]).val()
            };
            datalist.push(obj);
        }
        $http({
            method: 'POST',
            url: '../SafetyIndex/AddIndexForm',
            data: { 'ItemList': datalist }
        })
            .success(function (ret) {
                $scope.DataLoading = false;
                common.success($scope, null, ret);

                if (ret.Code == 100) {
                    alertify.alert("保存成功！");
                    setTimeout(function () {
                        window.location.href = "SafetyIndexFormList?page=" + 1;
                    }, 3000);
                } else
                    alertify.alert(ret.Msg);
            })
            .error(function (data, status, headers, config) {
                $scope.DataLoading = false;
            });
    }

    $scope.GetSafetyIndexFormList = function (model, page) {
        $scope.DataLoading = true;
        $scope.IndexFormList = [];
        $http({
            method: 'POST',
            url: '../SafetyIndex/GetSafetyIndexFormList',
            data: { 'model': model, 'page': page }
        })
            .success(function (ret) {
                $scope.DataLoading = false;
                common.success($scope, null, ret);
                $scope.IndexFormList = ret.Data.Data;
                $scope.TotalCount = ret.Data.TotalItemCount;
            })
            .error(function (data, status, headers, config) {
                $scope.DataLoading = false;
            });
    }

    $scope.GetIndexFormDetail = function (Id) {
        $scope.DataLoading = true;
        $scope.IndexFormList = [];
        $http({
            method: 'POST',
            url: '../SafetyIndex/GetIndexFormDetail',
            data: { 'FormId': Id }
        })
            .success(function (ret) {
                $scope.DataLoading = false;
                common.success($scope, null, ret);
                $scope.IndexForm = ret.Data;
                setTimeout(function () {
                    for (var i = 0; i < ret.Data.itemlist.length; i++) {
                        var item = ret.Data.itemlist[i];
                        $("#" + item.TypeId).val(item.DataValue);
                    }
                }, 1000);

            })
            .error(function (data, status, headers, config) {
                $scope.DataLoading = false;
            });
    }
    $scope.InitIndexPage = function () {
        $scope.Init_Chart1_1();
        $scope.Init_Chart2_1();
        $scope.Init_Chart8_1();
        $scope.Init_Chart9_1();

        $scope.Init_Chart1_2();
        $scope.Init_Chart2_2();
        $scope.Init_Chart8_2();
        $scope.Init_Chart9_2();

        $scope.Init_Chart3();
        $scope.GetEventList();
        $scope.InitTotalScore();
        $scope.Init_Chart0_1();

        setTimeout(function () {
            $scope.InitZB0();
            $scope.zb1();
            $scope.zb2();
            $scope.zb3();
            $scope.zb4();
        }, 2000);
    }

    $scope.Init_Chart1_2 = function () {
        var myChart2 = echarts.init(document.getElementById('echart1_2'));
        $http({
            method: 'POST',
            url: '../SafetyIndex/GetFactorValue',
            data: { 'TypeId': 2 }
        })
            .success(function (ret) {
                // 基于准备好的dom，初始化echarts实例
                var datalist = ret.Data;
                var namearray = [];
                var dataarray = [];
                for (var i = 0; i < datalist.length; i++) {
                    namearray.push(datalist[i].name);
                    dataarray.push(datalist[i].datavalue);
                }

                var option2 = {
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: {
                            lineStyle: {
                                color: '#57617B'
                            }
                        }
                    },
                    grid: {
                        left: '0',
                        right: '30',
                        top: '10',
                        bottom: '20',
                        containLabel: true
                    },
                    xAxis: [{
                        type: 'category',
                        boundaryGap: false,
                        axisLabel: {
                            show: true,
                            textStyle: {
                                color: 'rgba(255,255,255,.6)'
                            }
                        },
                        axisLine: {
                            lineStyle: {
                                color: 'rgba(255,255,255,.1)'
                            }
                        },
                        data: namearray//['10月1日', '10月2日', '10月3日', '10月4日', '10月5日', '10月6日', '10月7日', '10月8日', '10月9日', '10月10日', '10月11日', '10月12日']
                    }, {
                    }],
                    yAxis: [{
                        max: 30,
                        min: 0,

                        axisLabel: {
                            show: true,
                            textStyle: {
                                color: 'rgba(255,255,255,.6)'
                            }
                        },
                        axisLine: {
                            lineStyle: {
                                color: 'rgba(255,255,255,.1)'
                            }
                        },
                        splitLine: {
                            lineStyle: {
                                color: 'rgba(255,255,255,.1)'
                            }
                        }
                    }],
                    series: [{
                        name: '人员情况总指数',
                        type: 'line',
                        smooth: true,
                        symbol: 'circle',
                        symbolSize: 5,
                        showSymbol: false,
                        lineStyle: {
                            normal: {
                                width: 2
                            }
                        },
                        areaStyle: {
                            normal: {
                                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                    offset: 0,
                                    color: 'rgba(39, 122,206, 0.3)'
                                }, {
                                    offset: 0.8,
                                    color: 'rgba(39, 122,206, 0)'
                                }], false),
                                shadowColor: 'rgba(0, 0, 0, 0.1)',
                                shadowBlur: 10
                            }
                        },
                        itemStyle: {
                            normal: {
                                color: '#277ace',
                                borderColor: 'rgba(0,136,212,0.2)',
                                borderWidth: 12
                            }
                        },
                        data: dataarray,//[88, 89, 90, 95, 89, 92, 78, 75, 82, 88, 89, 96]
                        markLine: {
                            silent: true,
                            symbol: "none",
                            lineStyle: {
                                color: '#333'
                            },
                            data: [

                                {
                                    yAxis: 24,
                                    lineStyle: {               //警戒线的样式  ，虚实  颜色
                                        type: "dashed",
                                        color: "red"
                                    },
                                    label: {
                                        show: false,
                                        color: 'white'
                                    }

                                },
                                {
                                    yAxis: 25.5,
                                    lineStyle: {               //警戒线的样式  ，虚实  颜色
                                        type: "dashed",
                                        color: "orange"
                                    },
                                    label: {
                                        show: false,
                                        color: 'white'
                                    }

                                },
                                {
                                    yAxis: 27,
                                    lineStyle: {               //警戒线的样式  ，虚实  颜色
                                        type: "dashed",
                                        color: "yellow"
                                    },
                                    label: {
                                        show: false,
                                        color: 'white'
                                    }

                                },
                                {
                                    yAxis: 30,
                                    lineStyle: {               //警戒线的样式  ，虚实  颜色
                                        type: "dashed",
                                        color: "green"
                                    },
                                    label: {
                                        show: false,
                                        color: 'white'
                                    }

                                }
                            ]
                        }
                    }]
                };

                // 使用刚指定的配置项和数据显示图表。
                myChart2.setOption(option2);
                window.addEventListener("resize", function () {
                    myChart2.resize();
                });
            })
            .error(function (data, status, headers, config) {
                $scope.DataLoading = false;
            });


    }

    $scope.Init_Chart2_2 = function () {
        var myChart2 = echarts.init(document.getElementById('echart2_2'));
        $http({
            method: 'POST',
            url: '../SafetyIndex/GetFactorValue',
            data: { 'TypeId': 3 }
        })
            .success(function (ret) {
                // 基于准备好的dom，初始化echarts实例
                var datalist = ret.Data;
                var namearray = [];
                var dataarray = [];
                for (var i = 0; i < datalist.length; i++) {
                    namearray.push(datalist[i].name);
                    dataarray.push(datalist[i].datavalue);
                }

                var option2 = {
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: {
                            lineStyle: {
                                color: '#57617B'
                            }
                        }
                    },
                    grid: {
                        left: '0',
                        right: '20',
                        top: '10',
                        bottom: '20',
                        containLabel: true
                    },
                    xAxis: [{
                        type: 'category',
                        boundaryGap: false,
                        axisLabel: {
                            show: true,
                            textStyle: {
                                color: 'rgba(255,255,255,.6)'
                            }
                        },
                        axisLine: {
                            lineStyle: {
                                color: 'rgba(255,255,255,.1)'
                            }
                        },
                        data: namearray //['10月1日', '10月2日', '10月3日', '10月4日', '10月5日', '10月6日', '10月7日', '10月8日', '10月9日', '10月10日', '10月11日', '10月12日']
                    }, {




                    }],
                    yAxis: [{
                        max: 20,
                        min: 0,
                        axisLabel: {
                            show: true,
                            textStyle: {
                                color: 'rgba(255,255,255,.6)'
                            }
                        },
                        axisLine: {
                            lineStyle: {
                                color: 'rgba(255,255,255,.1)'
                            }
                        },
                        splitLine: {
                            lineStyle: {
                                color: 'rgba(255,255,255,.1)'
                            }
                        }
                    }],
                    series: [{
                        name: '机械因素指标',
                        type: 'line',
                        smooth: true,
                        symbol: 'circle',
                        symbolSize: 5,
                        showSymbol: false,
                        lineStyle: {
                            normal: {
                                width: 2
                            }
                        },
                        areaStyle: {
                            normal: {
                                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                    offset: 0,
                                    color: 'rgba(24, 163, 64, 0.3)'
                                }, {
                                    offset: 0.8,
                                    color: 'rgba(24, 163, 64, 0)'
                                }], false),
                                shadowColor: 'rgba(0, 0, 0, 0.1)',
                                shadowBlur: 10
                            }
                        },
                        itemStyle: {
                            normal: {
                                color: "#cdba00",
                                borderColor: 'rgba(0,136,212,0.2)',
                                borderWidth: 12
                            }
                        },
                        markLine: {
                            silent: true,
                            symbol: "none",
                            lineStyle: {
                                color: '#333'
                            },
                            data: [

                                {
                                    yAxis: 16,
                                    lineStyle: {               //警戒线的样式  ，虚实  颜色
                                        type: "dashed",
                                        color: "red"
                                    },
                                    label: {
                                        show: false,
                                        color: 'white'
                                    }

                                },
                                {
                                    yAxis: 17,
                                    lineStyle: {               //警戒线的样式  ，虚实  颜色
                                        type: "dashed",
                                        color: "orange"
                                    },
                                    label: {
                                        show: false,
                                        color: 'white'
                                    }

                                },
                                {
                                    yAxis: 18,
                                    lineStyle: {               //警戒线的样式  ，虚实  颜色
                                        type: "dashed",
                                        color: "yellow"
                                    },
                                    label: {
                                        show: false,
                                        color: 'white'
                                    }

                                },
                                {
                                    yAxis: 20,
                                    lineStyle: {               //警戒线的样式  ，虚实  颜色
                                        type: "dashed",
                                        color: "green"
                                    },
                                    label: {
                                        show: false,
                                        color: 'white'
                                    }

                                }
                            ]
                        },
                        data: dataarray //[88, 89, 90, 95, 89, 92, 78, 75, 82, 88, 89, 96]
                    }]
                };



                // 使用刚指定的配置项和数据显示图表。
                myChart2.setOption(option2);
                window.addEventListener("resize", function () {
                    myChart2.resize();
                });
            })
            .error(function (data, status, headers, config) {
                $scope.DataLoading = false;
            });


    }

    $scope.Init_Chart8_2 = function () {
        var myChart2 = echarts.init(document.getElementById('echart8_2'));
        $http({
            method: 'POST',
            url: '../SafetyIndex/GetFactorValue',
            data: { 'TypeId': 4 }
        })
            .success(function (ret) {
                // 基于准备好的dom，初始化echarts实例
                var datalist = ret.Data;
                var namearray = [];
                var dataarray = [];
                for (var i = 0; i < datalist.length; i++) {
                    namearray.push(datalist[i].name);
                    dataarray.push(datalist[i].datavalue);
                }

                var option2 = {
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: {
                            lineStyle: {
                                color: '#57617B'
                            }
                        }
                    },
                    grid: {
                        left: '0',
                        right: '20',
                        top: '10',
                        bottom: '20',
                        containLabel: true
                    },
                    xAxis: [{
                        type: 'category',
                        boundaryGap: false,
                        axisLabel: {
                            show: true,
                            textStyle: {
                                color: 'rgba(255,255,255,.6)'
                            }
                        },
                        axisLine: {
                            lineStyle: {
                                color: 'rgba(255,255,255,.1)'
                            }
                        },
                        data: namearray //['10月1日', '10月2日', '10月3日', '10月4日', '10月5日', '10月6日', '10月7日', '10月8日', '10月9日', '10月10日', '10月11日', '10月12日']
                    }, {




                    }],
                    yAxis: [{
                        max: 20,
                        min: 0,
                        axisLabel: {
                            show: true,
                            textStyle: {
                                color: 'rgba(255,255,255,.6)'
                            }
                        },
                        axisLine: {
                            lineStyle: {
                                color: 'rgba(255,255,255,.1)'
                            }
                        },
                        splitLine: {
                            lineStyle: {
                                color: 'rgba(255,255,255,.1)'
                            }
                        }
                    }],
                    series: [{

                        name: '环境因素指标',
                        type: 'line',
                        smooth: true,
                        symbol: 'circle',
                        symbolSize: 5,
                        showSymbol: false,
                        lineStyle: {
                            normal: {
                                width: 2
                            }
                        },
                        areaStyle: {
                            normal: {
                                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                    offset: 0,
                                    color: 'rgba(104, 33,122, 0.3)'
                                }, {
                                    offset: 0.8,
                                    color: 'rgba(39, 122,206, 0)'
                                }], false),
                                shadowColor: 'rgba(0, 0, 0, 0.1)',
                                shadowBlur: 10
                            }
                        },
                        itemStyle: {
                            normal: {
                                color: 'rgb(104,33,122)',
                                borderColor: 'rgba(0,136,212,0.2)',
                                borderWidth: 12
                            }
                        }, markLine: {
                            silent: true,
                            symbol: "none",
                            lineStyle: {
                                color: '#333'
                            },
                            data: [

                                {
                                    yAxis: 16,
                                    lineStyle: {               //警戒线的样式  ，虚实  颜色
                                        type: "dashed",
                                        color: "red"
                                    },
                                    label: {
                                        show: false,
                                        color: 'white'
                                    }

                                },
                                {
                                    yAxis: 17,
                                    lineStyle: {               //警戒线的样式  ，虚实  颜色
                                        type: "dashed",
                                        color: "orange"
                                    },
                                    label: {
                                        show: false,
                                        color: 'white'
                                    }

                                },
                                {
                                    yAxis: 18,
                                    lineStyle: {               //警戒线的样式  ，虚实  颜色
                                        type: "dashed",
                                        color: "yellow"
                                    },
                                    label: {
                                        show: false,
                                        color: 'white'
                                    }

                                },
                                {
                                    yAxis: 20,
                                    lineStyle: {               //警戒线的样式  ，虚实  颜色
                                        type: "dashed",
                                        color: "green"
                                    },
                                    label: {
                                        show: false,
                                        color: 'white'
                                    }

                                }
                            ]
                        },
                        data: dataarray//[88, 89, 90, 95, 89, 92, 78, 75, 82, 88, 89, 96]
                    }]
                };


                // 使用刚指定的配置项和数据显示图表。
                myChart2.setOption(option2);
                window.addEventListener("resize", function () {
                    myChart2.resize();
                });
            })
            .error(function (data, status, headers, config) {
                $scope.DataLoading = false;
            });


    }

    $scope.Init_Chart9_2 = function () {
        var myChart2 = echarts.init(document.getElementById('echart9_2'));
        $http({
            method: 'POST',
            url: '../SafetyIndex/GetFactorValue',
            data: { 'TypeId': 5 }
        })
            .success(function (ret) {
                // 基于准备好的dom，初始化echarts实例
                var datalist = ret.Data;
                var namearray = [];
                var dataarray = [];
                for (var i = 0; i < datalist.length; i++) {
                    namearray.push(datalist[i].name);
                    dataarray.push(datalist[i].datavalue);
                }

                var option2 = {
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: {
                            lineStyle: {
                                color: '#57617B'
                            }
                        }
                    },
                    grid: {
                        left: '0',
                        right: '20',
                        top: '10',
                        bottom: '20',
                        containLabel: true
                    },
                    xAxis: [{
                        type: 'category',
                        boundaryGap: false,
                        axisLabel: {
                            show: true,
                            textStyle: {
                                color: 'rgba(255,255,255,.6)'
                            }
                        },
                        axisLine: {
                            lineStyle: {
                                color: 'rgba(255,255,255,.1)'
                            }
                        },
                        data: namearray //['10月1日', '10月2日', '10月3日', '10月4日', '10月5日', '10月6日', '10月7日', '10月8日', '10月9日', '10月10日', '10月11日', '10月12日']
                    }, {




                    }],
                    yAxis: [{
                        max: 30,
                        min: 0,
                        axisLabel: {
                            show: true,
                            textStyle: {
                                color: 'rgba(255,255,255,.6)'
                            }
                        },
                        axisLine: {
                            lineStyle: {
                                color: 'rgba(255,255,255,.1)'
                            }
                        },
                        splitLine: {
                            lineStyle: {
                                color: 'rgba(255,255,255,.1)'
                            }
                        }
                    }],
                    series: [{
                        name: '管理因素指标',
                        type: 'line',
                        smooth: true,
                        symbol: 'circle',
                        symbolSize: 5,
                        showSymbol: false,
                        lineStyle: {
                            normal: {
                                width: 2
                            }
                        },
                        areaStyle: {
                            normal: {
                                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                    offset: 0,
                                    color: 'rgba(98,201,141, 0.3)'
                                }, {
                                    offset: 0.8,
                                    color: 'rgba(39, 122,206, 0)'
                                }], false),
                                shadowColor: 'rgba(0, 0, 0, 0.1)',
                                shadowBlur: 10
                            }
                        },
                        itemStyle: {
                            normal: {
                                color: 'rgb(98,201,141)',
                                borderColor: 'rgba(0,136,212,0.2)',
                                borderWidth: 12
                            }
                        },
                        data: dataarray,//[88, 89, 90, 95, 89, 92, 78, 75, 82, 88, 89, 96]
                        markLine: {
                            silent: true,
                            symbol: "none",
                            lineStyle: {
                                color: '#333'
                            },
                            data: [

                                {
                                    yAxis: 24,
                                    lineStyle: {               //警戒线的样式  ，虚实  颜色
                                        type: "dashed",
                                        color: "red"
                                    },
                                    label: {
                                        show: false,
                                        color: 'white'
                                    }

                                },
                                {
                                    yAxis: 25.5,
                                    lineStyle: {               //警戒线的样式  ，虚实  颜色
                                        type: "dashed",
                                        color: "orange"
                                    },
                                    label: {
                                        show: false,
                                        color: 'white'
                                    }

                                },
                                {
                                    yAxis: 27,
                                    lineStyle: {               //警戒线的样式  ，虚实  颜色
                                        type: "dashed",
                                        color: "yellow"
                                    },
                                    label: {
                                        show: false,
                                        color: 'white'
                                    }

                                },
                                {
                                    yAxis: 30,
                                    lineStyle: {               //警戒线的样式  ，虚实  颜色
                                        type: "dashed",
                                        color: "green"
                                    },
                                    label: {
                                        show: false,
                                        color: 'white'
                                    }

                                }
                            ]
                        }
                    }]
                };

                // 使用刚指定的配置项和数据显示图表。
                myChart2.setOption(option2);
                window.addEventListener("resize", function () {
                    myChart2.resize();
                });
            })
            .error(function (data, status, headers, config) {
                $scope.DataLoading = false;
            });


    }

    $scope.Init_Chart3 = function () {
        var myChart2 = echarts.init(document.getElementById('echart3'));
        $http({
            method: 'POST',
            url: '../SafetyIndex/GetFactorValue',
            data: { 'TypeId': 1 }
        })
            .success(function (ret) {
                // 基于准备好的dom，初始化echarts实例
                var datalist = ret.Data;
                var namearray = [];
                var dataarray = [];
                for (var i = 0; i < datalist.length; i++) {
                    namearray.push(datalist[i].name);
                    dataarray.push(datalist[i].datavalue);
                }

                var option = {
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: {
                            lineStyle: {
                                color: '#57617B'
                            }
                        }
                    },
                    grid: {
                        left: '0',
                        right: '20',
                        top: '10',
                        bottom: '20',
                        containLabel: true
                    },
                    xAxis: [{
                        type: 'category',
                        boundaryGap: false,
                        axisLabel: {
                            show: true,
                            textStyle: {
                                color: 'rgba(255,255,255,.6)'
                            }
                        },
                        axisLine: {
                            lineStyle: {
                                color: 'rgba(255,255,255,.1)'
                            }
                        },
                        data: namearray //['10月1日', '10月2日', '10月3日', '10月4日', '10月5日', '10月6日', '10月7日', '10月8日', '10月9日', '10月10日', '10月11日', '10月12日']
                    }, {




                    }],
                    yAxis: [{
                        max: 100,
                        min: 50,
                        axisLabel: {
                            show: true,
                            textStyle: {
                                color: 'rgba(255,255,255,.6)'
                            }
                        },
                        axisLine: {
                            lineStyle: {
                                color: 'rgba(255,255,255,.1)'
                            }
                        },
                        splitLine: {
                            lineStyle: {
                                color: 'rgba(255,255,255,.1)'
                            }
                        }
                    }],
                    series: [{
                        name: '生产安全总指数',
                        type: 'line',
                        smooth: true,
                        symbol: 'circle',
                        symbolSize: 5,
                        showSymbol: false,
                        lineStyle: {
                            normal: {
                                width: 2
                            }
                        },
                        areaStyle: {
                            normal: {
                                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                    offset: 0,
                                    color: 'rgba(39, 122,206, 0.3)'
                                }, {
                                    offset: 0.8,
                                    color: 'rgba(39, 122,206, 0)'
                                }], false),
                                shadowColor: 'rgba(0, 0, 0, 0.1)',
                                shadowBlur: 10
                            }
                        },
                        itemStyle: {
                            normal: {
                                color: '#277ace',
                                borderColor: 'rgba(0,136,212,0.2)',
                                borderWidth: 12
                            }
                        },
                        data: dataarray,
                        markLine: {
                            silent: true,
                            symbol: "none",
                            lineStyle: {
                                color: '#333'
                            },
                            data: [

                                {
                                    yAxis: 80,
                                    lineStyle: {               //警戒线的样式  ，虚实  颜色
                                        type: "dashed",
                                        color: "red"
                                    },
                                    label: {
                                        show: true,
                                        color: 'white'
                                    }

                                },
                                {
                                    yAxis: 85,
                                    lineStyle: {               //警戒线的样式  ，虚实  颜色
                                        type: "dashed",
                                        color: "orange"
                                    },
                                    label: {
                                        show: true,
                                        color: 'white'
                                    }

                                },
                                {
                                    yAxis: 90,
                                    lineStyle: {               //警戒线的样式  ，虚实  颜色
                                        type: "dashed",
                                        color: "yellow"
                                    },
                                    label: {
                                        show: true,
                                        color: 'white'
                                    }

                                },
                                {
                                    yAxis: 100,
                                    lineStyle: {               //警戒线的样式  ，虚实  颜色
                                        type: "dashed",
                                        color: "green"
                                    },
                                    label: {
                                        show: true,
                                        color: 'white'
                                    }

                                }
                            ]
                        }
                    }]
                };

                // 使用刚指定的配置项和数据显示图表。
                myChart2.setOption(option);
                window.addEventListener("resize", function () {
                    myChart2.resize();
                });
            })
            .error(function (data, status, headers, config) {
                $scope.DataLoading = false;
            });


    }

    $scope.Init_Chart1_1 = function () {
        var colorlist = ['#62c98d', '#2f89cf', '#4cb9cf', '#53b666', '#62c98d', '#205acf', '#c9c862', '#c98b62', '#c962b9', '#7562c9', '#c96262', '#c25775', '#00b7be'];
        var myChart = echarts.init(document.getElementById('echart1_1'));
        $http({
            method: 'POST',
            url: '../SafetyIndex/GetFactorPie',
            data: { 'TypeId': 2 }
        })
            .success(function (ret) {
                // 基于准备好的dom，初始化echarts实例
                var datalist = ret.Data;
                var datas = [];
                for (var i = 0; i < datalist.length; i++) {
                    var obj = {
                        'value': datalist[i].Percent,
                        'name': datalist[i].IndexName

                    };
                    datas.push(obj);
                }
                var option1 = {
                    tooltip: {
                        trigger: 'item',
                        formatter: "{b} : ({d}%)"
                    },
                    calculable: true,
                    series: [
                        {
                            label: {
                                color: 'inherit',
                                alignTo: 'edge',
                                formatter: '{b}\n{d}% ',
                                minMargin: 5,
                                edgeDistance: 10,
                                lineHeight: 15

                            },
                            name: '',
                            color: colorlist,
                            type: 'pie',
                            radius: [30, 70],
                            center: ['50%', '50%'],
                            roseType: 'radius',
                            data: datas
                        }
                    ]
                };
                // 使用刚指定的配置项和数据显示图表。
                myChart.setOption(option1);
                window.addEventListener("resize", function () {
                    myChart.resize();
                });

            })
            .error(function (data, status, headers, config) {
                $scope.DataLoading = false;
            });
    }

    $scope.Init_Chart2_1 = function () {
        var myChart = echarts.init(document.getElementById('echart2_1'));
        $http({
            method: 'POST',
            url: '../SafetyIndex/GetFactorPie',
            data: { 'TypeId': 3 }
        })
            .success(function (ret) {
                // 基于准备好的dom，初始化echarts实例
                var datalist = ret.Data;
                var datas = [];
                for (var i = 0; i < datalist.length; i++) {
                    var obj = {
                        'name': datalist[i].IndexName,
                        'value': datalist[i].Percent
                    };
                    datas.push(obj);
                }
                var option1 = {
                    tooltip: {
                        trigger: 'item',
                        formatter: "{b} : ({d}%)"
                    },

                    calculable: true,
                    series: [
                        {
                            name: '',
                            color: ['#62c98d', '#2f89cf', '#4cb9cf', '#53b666', '#62c98d', '#205acf', '#c9c862', '#c98b62', '#c962b9', '#c96262'],
                            type: 'pie',
                            //饼图的半径，数组的第一项是内半径，第二项是外半径
                            radius: [41, 65],
                            //支持设置成百分比，设置成百分比时第一项是相对于容器宽度，第二项是相对于容器高度
                            center: ['50%', '50%'],
                            //是否启用防止标签重叠策略，默认开启，圆环图这个例子中需要强制所有标签放在中心位置，可以将该值设为 false。
                            label: {
                                color: 'inherit',
                                alignTo: 'edge',
                                formatter: '{b}\n{d}% ',
                                minMargin: 5,
                                edgeDistance: 10,
                                lineHeight: 15

                            },
                            labelLine: {
                                normal: {
                                    show: true,
                                    length2: 1,
                                },
                                emphasis: {
                                    show: true
                                }
                            },
                            data: datas
                        }
                    ]
                };
                // 使用刚指定的配置项和数据显示图表。
                myChart.setOption(option1);
                window.addEventListener("resize", function () {
                    myChart.resize();
                });

            })
            .error(function (data, status, headers, config) {
                $scope.DataLoading = false;
            });
    }

    $scope.Init_Chart8_1 = function () {
        var myChart = echarts.init(document.getElementById('echart8_1'));
        $http({
            method: 'POST',
            url: '../SafetyIndex/GetFactorPie',
            data: { 'TypeId': 4 }
        })
            .success(function (ret) {
                // 基于准备好的dom，初始化echarts实例
                var datalist = ret.Data;
                var datas = [];
                for (var i = 0; i < datalist.length; i++) {
                    var obj = {
                        'name': datalist[i].IndexName,
                        'value': datalist[i].Percent
                    };
                    datas.push(obj);
                }
                var option1 = {
                    tooltip: {
                        trigger: 'item',
                        formatter: "{b} : ({d}%)"
                    },
                    calculable: true,
                    series: [
                        {
                            label: {
                                color: 'inherit',
                                alignTo: 'edge',
                                formatter: '{b}\n{d}% ',
                                minMargin: 5,
                                edgeDistance: 10,
                                lineHeight: 15

                            },
                            labelLine: {
                                length: 15,
                                length2: 0,
                                maxSurfaceAngle: 80
                            },
                            name: ' ',
                            color: ['#c98b62', '#c96262', '#4cb9cf', '#7562c9', '#62c98d', '#205acf', '#c9c862', '#c98b62', '#c962b9', '#7562c9', '#c96262', '#c25775', '#00b7be'],
                            type: 'pie',
                            radius: [30, 60],
                            center: ['50%', '50%'],


                            data: datas
                        }
                    ]
                };
                // 使用刚指定的配置项和数据显示图表。
                myChart.setOption(option1);
                window.addEventListener("resize", function () {
                    myChart.resize();
                });

            })
            .error(function (data, status, headers, config) {
                $scope.DataLoading = false;
            });
    }

    $scope.Init_Chart0_1 = function () {
        var myChart = echarts.init(document.getElementById('totalchart'));
        $http({
            method: 'POST',
            url: '../SafetyIndex/GetFactorPie',
            data: { 'TypeId': 1 }
        })
            .success(function (ret) {
                // 基于准备好的dom，初始化echarts实例
                var datalist = ret.Data;
                var datas = [];
                for (var i = 0; i < datalist.length; i++) {
                    var obj = {
                        'name': datalist[i].IndexName,
                        'value': datalist[i].Percent
                    };
                    datas.push(obj);
                }
                var option1 = {
                    tooltip: {
                        trigger: 'item',
                        formatter: "{b} : ({d}%)"
                    },
                    calculable: true,
                    series: [
                        {
                            name: ' ',
                            color: ['#c98b62', '#c96262', '#4cb9cf', '#7562c9', '#62c98d', '#205acf', '#c9c862', '#c98b62', '#c962b9', '#7562c9', '#c96262', '#c25775', '#00b7be'],
                            type: 'pie',
                            center: ['50%', '50%'],
                            radius: [40, 80],
                            label: {
                                normal: {
                                    position: 'inside',
                                    formatter: '{b}\n{d}% ',
                                    textStyle: {
                                        fontSize: 13,
                                        color: 'white'
                                    },
                                }
                            },


                            data: datas
                        }
                    ]
                };
                // 使用刚指定的配置项和数据显示图表。
                myChart.setOption(option1);
                window.addEventListener("resize", function () {
                    myChart.resize();
                });

            })
            .error(function (data, status, headers, config) {
                $scope.DataLoading = false;
            });
    }

    $scope.InitZB0 = function () {
        var myChart = echarts.init(document.getElementById('zb0'));
        $http({
            method: 'POST',
            url: '../SafetyIndex/GetCurrentTypeScore',
        })
            .success(function (ret) {
                // 基于准备好的dom，初始化echarts实例
                var datalist = ret.Data;
                var datas = [];
                var namelist = [];
                var vlist = [];
                for (var i = 0; i < datalist.length; i++) {
                    namelist.push(datalist[i].TypeId);
                    vlist.push(datalist[i].Score);
                }
                var option = {
                    tooltip: {
                        show: false
                    },
                    grid: {
                        top: '0%',
                        left: '65',
                        right: '0%',
                        bottom: '0%',
                    },
                    xAxis: {
                        min: 0,
                        max: 100,
                        splitLine: {
                            show: false
                        },
                        axisTick: {
                            show: false
                        },
                        axisLine: {
                            show: false
                        },
                        axisLabel: {
                            show: false
                        }
                    },
                    yAxis: {
                        inverse: true,
                        data: namelist,//['人的因素', '物的因素', '环境因素', '管理因素', '否决项'],
                        //offset: 15,
                        axisTick: {
                            show: false
                        },
                        axisLine: {
                            show: false
                        },
                        axisLabel: {
                            color: 'rgba(255,255,255,.9)',
                            fontSize: 14
                        }
                    },
                    series: [{
                        type: 'bar',
                        label: {
                            show: true,
                            zlevel: 10000,
                            position: 'right',
                            padding: 10,
                            color: '#49bcf7',
                            fontSize: 14,
                            formatter: '{c}分'

                        },
                        itemStyle: {
                            color: '#49bcf7'
                        },
                        barWidth: '15',
                        data: vlist,//[30, 30, 20, 20, 0],
                        z: 10
                    }, {
                        type: 'bar',
                        barGap: '-100%',
                        itemStyle: {
                            color: '#fff',
                            opacity: 0.1
                        },
                        barWidth: '15',
                        data: [100,100, 100, 100,100],
                        z: 5
                    }],
                };
                // 使用刚指定的配置项和数据显示图表。
                myChart.setOption(option);
                window.addEventListener("resize", function () {
                    myChart.resize();
                });



            })
            .error(function (data, status, headers, config) {
                $scope.DataLoading = false;
            });
    }


    $scope.Init_Chart9_1 = function () {
        var myChart = echarts.init(document.getElementById('echart9_1'));
        $http({
            method: 'POST',
            url: '../SafetyIndex/GetFactorPie',
            data: { 'TypeId': 5 }
        })
            .success(function (ret) {
                // 基于准备好的dom，初始化echarts实例
                var datalist = ret.Data;
                var datas = [];
                for (var i = 0; i < datalist.length; i++) {
                    var obj = {
                        'name': datalist[i].IndexName,
                        'value': datalist[i].Percent
                    };
                    datas.push(obj);
                }
                var option1 = {
                    tooltip: {
                        trigger: 'item',
                        formatter: "{b} : ({d}%)"
                    },
                    calculable: true,
                    series: [
                        {
                            name: ' ',
                            color: ['#c98b62', '#c96262', '#4cb9cf', '#7562c9', '#62c98d', '#205acf', '#c9c862', '#c98b62', '#c962b9', '#7562c9', '#c96262', '#c25775', '#00b7be'],
                            type: 'pie',
                            center: ['50%', '50%'],
                            label: {
                                color: 'inherit',
                                normal: {
                                    formatter: '{b}\n{d}% ',
                                    textStyle: {
                                        fontSize: 13,
                                        color: 'inherit'
                                    },
                                }
                            },


                            data: datas
                        }
                    ]
                };
                // 使用刚指定的配置项和数据显示图表。
                myChart.setOption(option1);
                window.addEventListener("resize", function () {
                    myChart.resize();
                });

            })
            .error(function (data, status, headers, config) {
                $scope.DataLoading = false;
            });
    }

    $scope.BindDepartmentList = function (control, defaultvalue) {
        $scope.PageLoading = true;
        $("#" + control).empty();
        $http({
            method: 'POST',
            url: '../SystemConfig/GetDepartmentList'
        })
            .success(function (ret) {
                $scope.PageLoading = false;
                common.success($scope, null, ret);

                if (ret.Code == 100) {
                    $("#" + control).append('<option value="" selected>选择部门</option>');
                    $.each(ret.Data, function (i, n) {
                        if (n.DepartmentName != "系统支持") {
                            if (defaultvalue != null) {
                                if (n.Id == defaultvalue)
                                    $("#" + control).append($compile("<option selected='selected' value=\"" + n.Id + "\">" + n.DepartmentName + "</option>")($scope));
                                else
                                    $("#" + control).append($compile("<option value=\"" + n.Id + "\">" + n.DepartmentName + "</option>")($scope));
                            }
                            else {
                                $("#" + control).append($compile("<option value=\"" + n.Id + "\">" + n.DepartmentName + "</option>")($scope));
                            }
                        }
                    })
                    $("#" + control).selectpicker('refresh');
                }
                else {
                    alertify.alert(ret.Msg);
                }
            })
            .error(function (data, status, headers, config) {
                alertify.alert("请检查网络");
            });
    }
    $scope.InitTotalScore = function () {
        $http({
            method: 'POST',
            url: '../SafetyIndex/GetCurrentScore'
        })
            .success(function (ret) {
                common.success($scope, null, ret);
                $scope.TotalScore = ret.Data;
                var myChart = echarts.init(document.getElementById('TotalScore'));
                var option = {
                    series: [{
                        type: 'gauge',
                        startAngle: 200,
                        endAngle: -20,
                        radius: '110%',
                        min: 0,
                        max: 100,
                        splitNumber: 5,
                        center: ['50%', '65%'],
                        axisLine: {
                            distance: -60,
                            lineStyle: {
                                width: 4,
                                color: [
                                    [0.8, 'red'],
                                    [0.85, 'orange'],
                                    [0.9, 'yellow'],
                                    [1, 'green']
                                ]
                            }
                        },
                        pointer: {
                            icon: 'path://M12.8,0.7l12,40.1H0.7L12.8,0.7z',
                            length: '86%',
                            width: 5,
                            offsetCenter: [0, '0%'],
                            itemStyle: {
                                color: 'auto'
                            }
                        },
                        axisTick: {
                            distance: 2,
                            length: 5,
                            lineStyle: {
                                color: 'white',
                                width: 2
                            }
                        },
                        axisLabel: {
                            color: 'white'
                        },
                        splitLine: {
                            length: 1,
                            lineStyle: {
                                color: 'white',
                                width: 2
                            }
                        },

                        title: {
                            offsetCenter: [0, '-20%'],
                            fontSize: 25,
                            textStyle: {
                                color: 'white'
                            }
                        },
                        detail: {
                            show: true,
                            fontSize: 28,
                            offsetCenter: [0, 45],
                            valueAnimation: true,
                            formatter: function (value) {
                                return value;
                            },
                            color: 'auto'
                        },
                        data: [{
                            value: ret.Data,
                            name: ''
                        }]
                    }]
                };
                myChart.setOption(option);
                window.addEventListener("resize", function () {
                    myChart.resize();
                });

            })
            .error(function (data, status, headers, config) {
                $scope.DataLoading = false;
            });



    }



    $scope.zb1 = function () {
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('zb1'));
        var v1 = $scope.DetailScore.zb1;
        var v2 = $scope.DetailScore.zb0 - $scope.DetailScore.zb1;
        var v3 = $scope.DetailScore.zb0;
        option = {
            series: [{
                type: 'pie',
                radius: ['60%', '70%'],
                color: '#49bcf7',
                label: {
                    normal: {
                        position: 'center'
                    }
                },
                data: [{
                    value: v1,
                    name: '人的因素',
                    label: {
                        normal: {
                            formatter: function (params) {
                                return '占比' + Math.round(v1 / v3 * 100) + '%'
                            },
                            textStyle: {
                                fontSize: 12,
                                color: '#fff',
                            }
                        }
                    }
                }, {
                    value: v2,
                    name: '其他',
                    label: {
                        normal: {
                            formatter: function (params) {
                                return '占比' + Math.round(v1 / v3 * 100) + '%'
                            },
                            textStyle: {
                                color: '#aaa',
                                fontSize: 12
                            }
                        }
                    },
                    itemStyle: {
                        normal: {
                            color: 'rgba(255,255,255,.2)'
                        },
                        emphasis: {
                            color: '#fff'
                        }
                    },
                }]
            }]
        };
        myChart.setOption(option);
        window.addEventListener("resize", function () {
            myChart.resize();
        });
    }

    $scope.zb2 = function () {
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('zb2'));
        var v1 = $scope.DetailScore.zb2;
        var v2 = $scope.DetailScore.zb0 - $scope.DetailScore.zb2;
        var v3 = $scope.DetailScore.zb0;
        option = {
            series: [{
                type: 'pie',
                radius: ['60%', '70%'],
                color: '#cdba00',
                label: {
                    normal: {
                        position: 'center'
                    }
                },
                data: [{
                    value: v1,
                    name: '物的因素',
                    label: {
                        normal: {
                            formatter: v1 + '',
                            textStyle: {
                                fontSize: 20,
                                color: '#fff',
                            }
                        }
                    }
                }, {
                    value: v2,
                    name: '其他',
                    label: {
                        normal: {
                            formatter: function (params) {
                                return '占比' + Math.round(v1 / v3 * 100) + '%'
                            },
                            textStyle: {
                                color: '#aaa',
                                fontSize: 12
                            }
                        }
                    },
                    itemStyle: {
                        normal: {
                            color: 'rgba(255,255,255,.2)'
                        },
                        emphasis: {
                            color: '#fff'
                        }
                    },
                }]
            }]
        };
        myChart.setOption(option);
        window.addEventListener("resize", function () {
            myChart.resize();
        });
    }

    $scope.zb3 = function () {
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('zb3'));
        var v1 = $scope.DetailScore.zb0 - $scope.DetailScore.zb3;
        var v2 = $scope.DetailScore.zb3;
        var v3 = $scope.DetailScore.zb0;
        option = {
            series: [{

                type: 'pie',
                radius: ['60%', '70%'],
                color: 'rgb(114,36,234)',
                label: {
                    normal: {
                        position: 'center'
                    }
                },
                data: [{
                    value: v2,
                    name: '环境因素',
                    label: {
                        normal: {
                            formatter: v2 + '',
                            textStyle: {
                                fontSize: 20,
                                color: '#fff',
                            }
                        }
                    }
                }, {
                    value: v1,
                    name: '占比',
                    label: {
                        normal: {
                            formatter: function (params) {
                                return '占比' + Math.round(v2 / v3 * 100) + '%'
                            },
                            textStyle: {
                                color: '#aaa',
                                fontSize: 12
                            }
                        }
                    },
                    itemStyle: {
                        normal: {
                            color: 'rgba(255,255,255,.2)'
                        },
                        emphasis: {
                            color: '#fff'
                        }
                    },
                }]
            }]
        };
        myChart.setOption(option);
        window.addEventListener("resize", function () {
            myChart.resize();
        });
    }

    $scope.zb4 = function () {
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('zb4'));
        var v1 = $scope.DetailScore.zb0 - $scope.DetailScore.zb4;
        var v2 = $scope.DetailScore.zb4;
        var v3 = $scope.DetailScore.zb0;
        option = {
            series: [{

                type: 'pie',
                radius: ['60%', '70%'],
                color: '#62c98d',
                label: {
                    normal: {
                        position: 'center'
                    }
                },
                data: [{
                    value: v2,
                    name: '管理因素',
                    label: {
                        normal: {
                            formatter: v2 + '',
                            textStyle: {
                                fontSize: 20,
                                color: '#fff',
                            }
                        }
                    }
                }, {
                    value: v1,
                    name: '',
                    label: {
                        normal: {
                            formatter: function (params) {
                                return '占比' + Math.round(v2 / v3 * 100) + '%'
                            },
                            textStyle: {
                                color: '#aaa',
                                fontSize: 12
                            }
                        }
                    },
                    itemStyle: {
                        normal: {
                            color: 'rgba(255,255,255,.2)'
                        },
                        emphasis: {
                            color: '#fff'
                        }
                    },
                }]
            }]
        };
        myChart.setOption(option);
        window.addEventListener("resize", function () {
            myChart.resize();
        });
    }

});